/***************************************************************************
 *   Copyright (C) 2008 by Goliash   *
 *   goliash@goliash.net   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef SCAN_DIALOG_H
#define SCAN_DIALOG_H

#include <poppler/qt4/poppler-qt4.h>
#include <QtSql>
#include <QDialog>
#include "ui_scan_dialog.h"
#include "medium.h"
#include "file.h"
#include "mainwindow.h"
#include "preferences.h"

#include "CImg.h"
#include <exiv2/image.hpp>
#include <exiv2/exif.hpp>
#include <id3/tag.h>


#include <iostream>
#include <string>
#include <sstream>
#include <fstream>

/**
 * The scan-medium dialog.
 */
class ScanDialog: public QDialog, private Ui::scan_dialog
{
	Q_OBJECT
	
	public:
		ScanDialog(QWidget *parent = 0, Medium *medium = 0);
		//void setMedium(Medium *medium);
		void scanMedium();
		void saveIntoDB();

		void processFilterJPEG(QString filename, File *file);
		void processFilterMp3(QString filename, File *file);
		void processFilterTxt(QString filename, File *file, QString suffix);
		void processFilterPdf(QString filename, File *file);

	public slots:
		/*void mediumChanged(int state);
		void refresh();*/
		void accept();
		void reject();
	signals:
		void valueChanged(int value);
	private:
		Medium *medium;
		QWidget *mw;
		void insertFileListToSql(QList<File *> list, int root_id, int parent_id, QSqlDatabase db);

		Preferences *prefs;
};


#endif // SCAN_DIALOG_H
